package com.vonchange.water.pvm.behavior;

import com.vonchange.water.pvm.execution.ActivityExecution;
import com.vonchange.water.pvm.model.definition.PvmActivity;
import com.vonchange.water.pvm.model.definition.PvmActivityConfig;
import com.vonchange.water.pvm.model.definition.PvmActivityField;

import javax.annotation.Resource;
import java.util.Map;


public class EmailActivityBehavior extends AbstractActivityBehavior{
    @Resource
    private EmailSendApi emailSendApi;
    @Override
    public void executeMain(ActivityExecution execution) throws Exception {
       PvmActivity activity = (PvmActivity) execution.getCurrentActivity();
       PvmActivityConfig  activityConfig = activity.getActivityConfig();
       Map<String,PvmActivityField> fieldMap= activityConfig.getFieldMap();
       // 流程变量并入fieldMap
       //获取属性 并映射到 发送邮箱实体类中
        ReqSendEmail reqSendEmail = convertFieldToModel(fieldMap);
        emailSendApi.sendEmail(reqSendEmail);
    }

    @Override
    public String activityType() {
        return "email";
    }



    private ReqSendEmail convertFieldToModel(Map<String,PvmActivityField> fieldMap) {
        return null;
    }
}
